# numbers = [1,2,3,4]

# for number in numbers:
#     if number % 2 == 0:
#         print(number)
        
# colors = ['red','yellow','green','blue']
# print(colors)
# colors[0] = "burgundy" # 索引修改
# colors[1:3] = ["orange","magenta"] # 切片赋值
# print(colors)
# colors[1:3] = ["orange","magenta","aqua"] 
# print(colors)
# ['red', 'yellow', 'green', 'blue']
# ['burgundy', 'orange', 'magenta', 'blue']
# ['burgundy', 'orange', 'magenta', 'aqua', 'blue']

# colors = ['red','yellow','green','blue']
# colors.insert(1,"orange")
# colors.pop(1)


# nums = [1,2,3,4,5]
# print(sum(nums),max(nums),min(nums))

# numbers = (1,2,3,4,5)
# squares = [num**4 for num in numbers]
# print(numbers,squares)

# first_tuple = (1,2,3)
# print(first_tuple,type(first_tuple),len(first_tuple),first_tuple[0],first_tuple[0:3])


# for item in first_tuple:
    # print(item*2)   # 返回 2 4 6
    
    
# coordinates = 5.21,8.29
# x,y = coordinates
# a,b,c,d = 1,2,3,4
# print(x,y,a,b,c,d)
import pandas as pd

# s = pd.Series([1,2,3,4,5],index=['a','b','c','d','e'])
# print(s)

# s = pd.Series([1,2,3,4,5])
# print(s)
# df = pd.read_csv("day1/data.csv")   
# print(df)   

# 获取数据
# print(df.head())
# print(df.tail())
# print(df.info())
# print(df.describe())

# 获取数据  

# 获取数据
# print(df.iloc[0])
# print(df.iloc[0:3])
# print(df.iloc[:,0])
# print(df.iloc[0:3,0])

# from sqlalchemy import create_engine

# 创建内存数据库引擎
# engine = create_engine('sqlite:///:memory:')
# engine = create_engine('mysql+mysqlconnector://root:dhcnm123@localhost:3306/test')

# 创建示例数据
df = pd.DataFrame({
    'id': [ 2,1,3],
    'name': ['张三', '王五', '李四'],
    'age': [30,25,35]
})
df2 = pd.DataFrame({
    'id': [ 2,11,32],
    'name': ['张三2', '王五2', '李四2'],
    'age': [30,252,352]
})

# 将数据写入数据库
# df.to_sql('my_table', engine, index=False)

# 现在可以查询数据了
# result = pd.read_sql("SELECT * FROM my_table;", engine)
# ser=result['age'] #获得姓名这列的所有数据
# ser = df.iloc[[0],[0]]
# print(ser)
# dict = {'name':["name1", "name2", "name3", "name4"], 
#         'degree': ["degree1", "degree2", "degree3", "degree4"], 
#         'score':[1, 2, 3, 4]} 
# df = pd.DataFrame(dict, index = [True, False, True, False]) 
# df['as'] = '指定的值'
# df['数学'] = 20
# df['英语'] = 30
# df['语文'] = 40
# df['总成绩'] = df['数学']+df['英语']+df['语文']
# df.columns = ['Column 1', 'Column 2', 'Column 3' ]
# aa = df.sort_values(by='name',ascending=False)
# df['age'].sub(2)
# aa = df['age'].sub(2)
# print(aa)

# df['age'].mul(2)
# aa = df['age'].mul(2)
# print(aa)

subject_id = pd.merge(df, df2, how='inner', on='age')

print(subject_id)